package com.mall.admin.controller;


import com.mall.admin.service.CmsSubjectService;
import com.mall.commons.utils.R;
import com.mall.domain.CmsSubject;
import com.mall.vo.MyPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/subject")
public class CmsSubjectController {

    @Autowired
    private CmsSubjectService cmsSubjectService;

    /**
     * 获取全部商品专题
     * 接口地址:/subject/listAll
     * @return
     */
    @GetMapping("/listAll")
    private R<List<CmsSubject>> listAll(){
        List<CmsSubject> cmsSubjects = cmsSubjectService.listAll();
        return R.success("操作成功!",cmsSubjects );
    }

    /**
     * 根据专题名称分页获取商品专题(分页查询)
     * 接口地址:/subject/list
     * @return
     */
    @GetMapping("/list")
    public R<MyPage<CmsSubject>> listByPage(@RequestParam(defaultValue = "1") Long pageNum,
                                            @RequestParam(defaultValue = "10") Long pageSize,
                                            String keyword){
        MyPage<CmsSubject> myPage = cmsSubjectService.listByPage(pageNum, pageSize, keyword);
        return R.success( "操作成功!",myPage);
    }

}
